package com.tvt.smsapp_demo;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.tvt.smsapp_demo.appconfig.reader.AppConfigReader;
import com.tvt.smsapp_demo.appconfig.xml.AppConfigXml;
import com.tvt.smsapp_demo.appconfig.xml.XSms;
import com.tvt.smsapp_demo.sms.SmsSender;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		AppConfigXml appConfig = AppConfigReader.decodeAppConfig(getApplicationContext(), "ConfigApp.xml");
		if(appConfig.getStartApp().isActiveSMS()){
			XSms sms = appConfig.getStartApp().getSms();
			SmsSender.sendTextSMS(sms);
		}
		
		String url = appConfig.getStartApp().getBrowserUrl();
		Intent urlIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
		startActivity(urlIntent);
		this.finish();
	}


}
